package com.example.demo.experiment2;

import static org.junit.Assert.*;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;

import com.example.TestCode.measurement.ThreePointOneLine;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
@RunWith(Parameterized.class)
public class ThreePointOneLineTest2 {

	private ThreePointOneLine t=null;
	@Before
	public void setUp() throws Exception {
		t=new ThreePointOneLine();
	}

	@After
	public void tearDown() throws Exception {
		t=null;
	}
	
	@Parameters
	public static Collection<?>data(){
		 Object obj[][]= new Object[7][7];
	        String csvFile = "D:\\isOneLine.csv";
	        int count=0;
	        try (BufferedReader br = new BufferedReader(new FileReader(csvFile))) {
	            String line;
	            while ((line = br.readLine()) != null) {
	                String[] data = line.split(",");
	                
	                for (int i = 0; i < data.length; i++) {
	                    System.out.print(data[i] + "\t");
	                }
	                System.out.println();
	                for(int i=0;i<data.length-1;i++) {
	                	obj[count][i]=Double.parseDouble(data[i]);
	                }
	                obj[count][data.length-1]=Boolean.parseBoolean(data[data.length-1]);
	                count++;
	            } 
	           }
	            catch (IOException e) {
	            e.printStackTrace();
	        }
		return Arrays.asList(obj);
	}
    double x1,y1,x2,y2,x3,y3;
    boolean expected;
	public ThreePointOneLineTest2(double x1,double y1,double x2,double y2,double x3,double y3,boolean expected) {
		this.x1=x1;
		this.y1=y1;
		this.x2=x2;
		this.y2=y2;
		this.x3=x3;
		this.y3=y3;
		this.expected=expected;
	}
	@Test
	public void testIsOneLine01() {
		//assertEquals(false, t.isOneLine(1, 2, 1, 2, 1, 2));
		assertEquals(expected, t.isOneLine(x1, y1, x2, y2, x3, y3));
	}
	
}
